import { computed } from "@vue/composition-api";
let catchlist = new Map();

export function useComputed(fn) {
    return function (...args) {
        let key = `${fn.name}_${JSON.stringify(args)}`;
        if (catchlist.get(key)) {
            return catchlist.get(key);
        }
        const result = computed(() => fn(...args));
        if (catchlist.size >= 100) {
            catchlist.clear();
        }
        catchlist.set(key, result);
        return result;
    };
}
